/*
 * Copyright (C) 2021 The Chinese Software International Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.tonyodev.fetch2.util;

import com.tonyodev.fetch2.EnqueueAction;
import com.tonyodev.fetch2.Error;
import com.tonyodev.fetch2.FetchFileServerDownloader;
import com.tonyodev.fetch2.HttpUrlConnectionDownloader;
import com.tonyodev.fetch2.NetworkType;
import com.tonyodev.fetch2.Priority;
import com.tonyodev.fetch2.PrioritySort;
import com.tonyodev.fetch2.Status;
import com.tonyodev.fetch2core.Downloader;
import com.tonyodev.fetch2core.FetchLogger;
import com.tonyodev.fetch2core.FileServerDownloader;
import com.tonyodev.fetch2core.Logger;

import org.jetbrains.annotations.NotNull;

/**
 * description Defaults
 *
 * @author liuluming
 * @since 2021-05-24
 */
public class Defaults {
    public static final int DEFAULT_GROUP_ID = 0;
    public static final long DEFAULT_UNIQUE_IDENTIFIER = 0L;
    public static final long DEFAULT_DOWNLOAD_SPEED_REPORTING_INTERVAL_IN_MILLISECONDS = 1000L;
    public static final long DEFAULT_HAS_ACTIVE_DOWNLOADS_INTERVAL_IN_MILLISECONDS = 300000L;
    public static final boolean DEFAULT_CREATE_FILE_ON_ENQUEUE = true;
    public static final int DEFAULT_CONCURRENT_LIMIT = 1;
    @NotNull
    public static final String EMPTY_JSON_OBJECT_STRING = "{}";
    public static final long DEFAULT_PRIORITY_QUEUE_INTERVAL_IN_MILLISECONDS = 500L;
    public static final boolean DEFAULT_AUTO_START = true;
    public static final boolean DEFAULT_RETRY_ON_NETWORK_GAIN = true;
    public static final int DEFAULT_FILE_SLICE_NO_LIMIT_SET = -1;
    @NotNull
    public static final String DEFAULT_INSTANCE_NAMESPACE = "LibGlobalFetchLib";
    public static final boolean DEFAULT_HASH_CHECK_ENABLED = false;
    public static final boolean DEFAULT_FILE_EXIST_CHECKS = true;
    public static final int DEFAULT_AUTO_RETRY_ATTEMPTS = 0;
    public static final int DEFAULT_GLOBAL_AUTO_RETRY_ATTEMPTS = -1;
    public static final boolean DEFAULT_ENABLE_LISTENER_NOTIFY_ON_ATTACHED = false;
    public static final boolean DEFAULT_ENABLE_LISTENER_NOTIFY_ON_REQUEST_UPDATED = true;
    public static final boolean DEFAULT_ENABLE_LISTENER_AUTOSTART_ON_ATTACHED = false;
    public static final boolean DEFAULT_DOWNLOAD_ON_ENQUEUE = true;
    public static final boolean DEFAULT_PREALLOCATE_FILE_ON_CREATE = true;
    public static final long DEFAULT_NOTIFICATION_TIMEOUT_AFTER_RESET = 31104000000L;
    public static final long DEFAULT_NOTIFICATION_TIMEOUT_AFTER = 10000L;
    @NotNull
    private static NetworkType defaultNetworkType;
    @NotNull
    private static NetworkType defaultGlobalNetworkType;
    @NotNull
    private static Priority defaultPriority;
    @NotNull
    private static Error defaultNoError;
    @NotNull
    private static Status defaultStatus;
    @NotNull
    private static PrioritySort defaultPrioritySort;
    @NotNull
    private static EnqueueAction defaultEnqueueAction;
    @NotNull
    private static Downloader defaultDownloader;
    @NotNull
    private static FileServerDownloader defaultFileServerDownloader;
    @NotNull
    private static Logger defaultLogger;

    @NotNull
    public static NetworkType getDefaultNetworkType() {
        return defaultNetworkType;
    }

    @NotNull
    public static NetworkType getDefaultGlobalNetworkType() {
        return defaultGlobalNetworkType;
    }

    @NotNull
    public static Priority getDefaultPriority() {
        return defaultPriority;
    }

    @NotNull
    public static Error getDefaultNoError() {
        return defaultNoError;
    }

    @NotNull
    public static Status getDefaultStatus() {
        return defaultStatus;
    }

    @NotNull
    public static PrioritySort getDefaultPrioritySort() {
        return defaultPrioritySort;
    }

    @NotNull
    public static EnqueueAction getDefaultEnqueueAction() {
        return defaultEnqueueAction;
    }

    @NotNull
    public static Downloader getDefaultDownloader() {
        return defaultDownloader;
    }

    @NotNull
    public static FileServerDownloader getDefaultFileServerDownloader() {
        return defaultFileServerDownloader;
    }

    @NotNull
    public static Logger getDefaultLogger() {
        return defaultLogger;
    }

    static {
        defaultNetworkType = NetworkType.ALL;
        defaultGlobalNetworkType = NetworkType.GLOBAL_OFF;
        defaultPriority = Priority.NORMAL;
        defaultNoError = Error.NONE;
        defaultStatus = Status.NONE;
        defaultPrioritySort = PrioritySort.ASC;
        defaultEnqueueAction = EnqueueAction.UPDATE_ACCORDINGLY;
        defaultDownloader = new HttpUrlConnectionDownloader(Downloader.FileDownloaderType.SEQUENTIAL);
        defaultFileServerDownloader = new FetchFileServerDownloader(Downloader.FileDownloaderType.SEQUENTIAL, 20_000);
        defaultLogger = new FetchLogger(false, "fetch2");
    }
}
